package com.cartagena.financo.dao;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import br.com.caelum.vraptor.ioc.Component;

import com.cartagena.financo.model.Term;
import com.cartagena.financo.repository.TermRepository;

@Component
public class TermDao extends BaseDao<Term> implements TermRepository {

    TermDao(Session session) {
        super(session);
    }

    @Override
    public Term loadByText(String term) {
        Criteria criteria = this.session.createCriteria(Term.class);
        criteria.add(Restrictions.eq("text", term));
        
        return (Term) criteria.uniqueResult();
    }

}
